public class OverrideDemo12 {
    public static void main(String[] args) {
        Flower mgh = new Flower();
        mgh.setName("玫瑰");
        mgh.setColor("黑色");
        System.out.println(mgh);

        Flower jh = new Flower();
        jh.setName("菊花");
        jh.setColor("白色");
        System.out.println(jh);
    }
}


class Plant {
    private String color;
    private String name;

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

//    @Override
//    public String toString() {
//        return "Plant{" +
//                "color='" + color + '\'' +
//                ", name='" + name + '\'' +
//                '}';
//    }
}

class Flower extends Plant {
    @Override
    public String toString() {
        return "这是一朵" + getColor() + "的" + getName();
    }
}

class Tree extends Plant {
    @Override
    public String toString() {
        return "这是一棵" + getColor() + "的" + getName();
    }
}
